;
$(function() {
    var Example = {
        init: function() {
            this.paging = '';
            this._render();
            this._bind();
        },
        _render: function() {
            console.log('Example init ...');
            // 弹出框
            $('#demo-dialog').dialog({
                title: 'My Dialog',
                width: 400,
                height: 200,
                closed: false,
                cache: false,
                modal: true
            });
            // 全局提示
            $.message.alert('警告', '这是一条警告！');
            // 分页组件
            this._renderPage(1);
            // 固定div
            $('.site-header').stickUp ? $('.site-header').stickUp({
                scrollHide: !0,
                zIndex: 999
            }) : '';
            // $('.alert-error').stickUp ? $('.alert-error').stickUp({
            //     zIndex: 9999
            // }) : '';
            // 回到顶部
            // $.scrollTop ? $.scrollTop({
            //        scrollName: 'scrollTop'
            //    }) : '';
        },
        _bind: function() {
            $(document).on('click', '.box-item', this['_animate']);
            // loadingbar start
            $(document).on('click', '#demo-loadingbar-start', this['_loadingbarStart']);
            $(document).on('click', '#demo-loadingbar-end', this['_loadingbarEnd']);
            // Message 全局提示
            $(document).on('click', '#demo-message-info', $.proxy(this['_messageInfo'], this));
            $(document).on('click', '#demo-message-danger', $.proxy(this['_messageDanger'], this));
            $(document).on('click', '#demo-message-warning', $.proxy(this['_messageWarning'], this));
            $(document).on('click', '#demo-message-success', $.proxy(this['_messageSuccess'], this));
        },
        _messageInfo: function() {},
        _messageDanger: function() {},
        _messageWarning: function() {},
        _messageSuccess: function() {},
        _loadingbarStart: function() {
            // $.loadingbar();
        },
        _loadingbarEnd: function() {},
        _renderPage: function(data) {
            var _this = this;
            _this.paging = $('#demo-pagination1').paging ? $('#demo-pagination1, #demo-pagination2').paging({
                page: data,
                count: 10000,
                prev: '上一页',
                next: '下一页',
                theme: 'hi',
                done: function(resultCode, data) {
                    if (resultCode == 'OK') {
                        _this._renderPage(data)
                        // _this.paging.setPage(data)
                    } else {
                        alert(data)
                    }
                }
            }) : '';
        },
        _animate: function(e) {
            if ($(this).hasClass('animated')) {
                $(this).attr('class', 'box-item');
            }
            var _this = this;
            setTimeout(function() {
                $(_this).addClass('animated ' + $(_this).attr('data-animation'));
            }, 0);
            setTimeout(function() {
                $(_this).attr('class', 'box-item');
            }, 2000);
        }
    };
    Example.init();
});